home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
reform16.zip
/
REFORMAT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-03-03
|
24KB
|
708 lines
{
To: INFO-IBMPC-REQUEST@USC-ISIB.ARPA
From: U001222%HNYKUN11.BITNET@WISCVM.WISC.EDU
Subject: reformat.pas
}
PROGRAM reformat;
{
Program to reformat any disk attached to an Olivetti PC or compatible.
The progam will work well on any MS/PC-DOS machine running under DOS
versions 2.00 up to and including 3.10. Fixed disks up to 32 Meg.
V1.50 Extensions made for big FATs. WORD.INC included for handling of
word integers. MS-DOS function INT21 / 32H used for drive information.
Corrected the problem of DOS losing track of the current directory.
The program has been tested under DOS 2.00 thru 3.10
It will probably work under DOS 3.20 too, but this version will not
run when you try to do so. If you want to test it with DOS 3.20, look
for the string DOS_Versions (it's somewhere near the end of the program)
in this program, and include that version number into the test.
Please let the author know whether you had success or not.
Jos Wennmacker July 86.
Universitair Rekencentrum
Geert Grooteplein Zuid 41
6525 GA Nijmegen
The Netherlands
BITNET address: U015415 at HNYKUN22
v1.6, 23 Nov 89 David Kirschbaum, Toad Hall
- Recoded for TP v5.0
V1.5 Jos added new 16-bit and word code, handling up to 30Meg
hard disks, etc. I cleaned up the integer math inline procedures
a little.
David Kirschbaum, Toad Hall
V1.23 Added FRAMER.INC, WRITEF.INC for framing, fast screen write,
fast screen line clear. Tightened up displays a little.
This version is now VERY PC-specific. Generic MS-DOS functions
for screen stuff to follow.
David Kirschbaum, Toad Hall.
V1.22 Added inline code to replace the INT25.ASM and INT26.ASM
files.
David Kirschbaum, Toad Hall, 3 May 86
V1.21(mod) not publicly released. Changes made by Rick Watson to let
the program recognize the big (16 bit) FATs. He made it run on 20 Meggers
under DOS 3.x. Martin Hobson made it run on 30 Meggers under DOS 3.x.
May 86.
V1.21 Small corrections made to avoid Turbo integer overflow. (Hey,
Borland, what about a WORD type in Turbo, would be very usefull using
the MSDOS features!).
V1.20 First release to the public domain.
What started as a favour to a friend grew into a nice program.
Do you like it? Let me know about it! If I know many people to use it,
I'll keep it up to date, and send you new releases.
Jos Wennmacker
}
{$A+} {word alignment to be nice}
{$B-} {short-circuit Boolean Eval}
{$D-} {no debug}
{$F-} {no far calls}
{$L-} {no local information}
{$R-} {no range checking}
{$S-} {no stack checking}
{$V-} {no string checking}
Uses Dos,Crt; {v1.6}
{-------------------------------- Global types -------------------------------}
TYPE
{------------------- types for word arithmetic see REFORMAT.IN1 -------------}
Relational_Operator = (Eq, Gt, Lt, Ne, Ge, Le);
{----------------------------- Bootrecord layout -----------------------------}
Boot = { the layout of the DOS boot record}
RECORD
Jump: ARRAY[0..2] OF Byte; { Near jump to boot code}
OEM : ARRAY[0..7] OF CHAR; { eight character OEM name}
sectorSize: word; { number of bytes in one sector}
clusterSize: Byte; { sectors per cluster}
reservedSectors: word; { DOS boot code sector(s) typically 1}
numberOfFATs: Byte; { usually 2, but often 1 for RAM disks}
rootDirSize, { maximum entries in root directory}
totalSectors: word; { total sectors in the logical image}
{ A limited description of the drive
bit 0 = 1: twosided, 0: not two-sided
bit 1 = 1: 8-sector, 0: not 8-sector
bit 2 = 1: removable 0: not removable
bits 3-7 must be set to 1
}
mediaDescriptor: Byte;
fatSize, { number of sectors in each FAT copy}
trackSize, { number of sectors per track}
numberOfHeads, { number of heads}
{ sectors hidden from DOS, preceding the DOS partition: including the
master boot record and any non-DOS partitions
}
hiddenSectors: word;
END;
{---------------- Layout of DOS function 32h disk parameter block ------------}
Parms_32 = ^Parameter_table;
Parameter_Table = { layout of the DOS function 32 table}
RECORD
assignedDisk, { 0 = A, 1 = B, ...}
altAD: Byte; { same as above, but 0 for RAM disk}
sectorSize: word; { number of bytes in one sector}
clusterSize_1, { sectors per cluster minus 1}
numberOfHeads_1: Byte; { number of heads minus 1}
reservedSectors: word; { DOS boot code sector(s) typically 1}
numberOfFATs: Byte; { usually 2, but often 1 for RAM disks}
rootDirSize, { maximum entries in root directory}
firstDataSector, { first sector for data storage}
totalDataClusters_1: word; { total data clusters plus 1}
fatSize: Byte; { number of sectors in each FAT copy}
firstDirectorySector: word; { first sector of the root directory}
(* v1.6
DeviceDriverAddress: ^byte; { Far (offset, segment) address of the
DOS device driver for the drive}
*)
DeviceDriverAddress: Pointer; {v1.6}
{ A limited description of the drive
only the low order byte is used:
bit 0 = 1: twosided, 0: not two-sided
bit 1 = 1: 8-sector, 0: not 8-sector
bit 2 = 1: removable 0: not removable
bits 3-7 must be set to 1
}
mediaDescriptor: word;
NextParameterTable: Parms_32; { far pointer to next disk table}
{ Starting cluster of current working directory.
According to Glenn Roberts in his May 86 PC Tech Journal article
"Finding Disk Parameters" this would only hold for PC DOS 2.00
}
currentDirCluster: word;
CurrentDirName: ARRAY [0..63] OF CHAR
{ The name of the current working directory. This does not hold for
DOS 3.x versions. Only for 2.00
}
END;
{-------- Long byte and integerarays for Disk Transfer Area, Fats etc. -------}
intArray = ARRAY[0..32766] OF Word; {v1.6 INTEGER;}
buffer = ARRAY[0..32766] OF Byte;
{--------------------- Element of tree of directory entries ------------------}
DirectoryPointer = ^DirectoryEntry;
(*v1.6 longInteger = ARRAY[0..1] OF INTEGER; *)
DirectoryEntry =
RECORD
{ name + extension w/o period
If the first char is $00, then this entry was never used.
Also the next entries in this directory have never been used.
If the first char is $E5, then this entry was erased.
}
EntryName: ARRAY[0..10] OF CHAR;
{ attribute of entry:
bit if set means
0 read only file
1 hidden file
2 system file
3 volume label
4 subdirectory
5 archive bit
}
attribute: Byte;
reserved: ARRAY[1..10] OF Byte; { for future use}
{ mapped in the bits:
< hh > < mm > < xx >
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
where:
hh binary number of hours [0..23]
mm binary number of minutes [0..59]
xx binary number of two-second
increments [0..28]
}
timeLastUpdated: word;
{ mapped in the bits
< yy > < mm > < dd >
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
where:
yy binary number of years [0..119]
(1980-2099)
mm binary number of month [1..129]
dd binary number of day [1..31]
}
dateLastUpdated: word;
startingCluster: word; { index of the file's first cluster}
fileSize: